﻿using System.Globalization;
using System.Windows.Data;

namespace Lib.WPF.Core;
/// <summary>
/// 百分比转换器
/// </summary>
public class PercentageConverter:IValueConverter {
    /// <summary>
    /// 
    /// </summary>

    public object Convert(object Value, Type TargetType, object Parameter, CultureInfo Culture) {
        if(Value is double BaseValue && double.TryParse(Parameter?.ToString(), Culture, out double Percentage)) {  
            return BaseValue * Percentage/100; 
        }
        return Value;
    }
    /// <summary>
    /// 
    /// </summary>
    public object ConvertBack(object Value, Type TargetType, object Parameter, CultureInfo Culture) {
        throw new NotImplementedException();
    }
}
